// pages/house/house.js
const app=getApp()
let length=0,length2=0,length3=0
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },
  listen:function(){
    
    wx.request({
      url: 'https://wx.xxmtcds.top:2333/user/get/music',
      method:'GET',
      name:'music',
      header:{
        'Content-Type': 'application/json',
        authorization:app.globalData.token
  
      },
      success:function(res){
        console.log(res.data)
        // console.log(num)

        wx.setStorageSync('arrA', res.data)
        length=res.data.length
        let num=parseInt(Math.random()*length)
        
        wx.setStorageSync('arr',{
          singer:res.data[num].music_singer,
          name:res.data[num].music_name,
          src:res.data[num].music_url,
          id:res.data[num].music_id,
          // list:res.data[num]
        })
        wx.request({
          url: 'https://wx.xxmtcds.top:2333/user/collectmusic',
          method:'GET',
          name:'collectList',
          header:{
           "Content-Type": "application/json",
           authorization:app.globalData.token
         },
         success:function(res){
          //  console.log(res)
          wx.setStorageSync('collect', res.data)
          wx.navigateTo({
            url: '/pages/listen/listen',
          })
         }
        })
       
        
      }
    })
  },
  vedio:function(){
    wx.request({
      url: 'https://wx.xxmtcds.top:2333/user/get/video',
      method:'GET',
      name:'music',
      header:{
        'Content-Type': 'application/json',
        authorization:app.globalData.token
  
      },
      success:function(res){
        console.log(res.data)
        // console.log(num)

        wx.setStorageSync('arrB', res.data)
        length2=res.data.length
        let num=parseInt(Math.random()*length2)
        
        wx.setStorageSync('arr2',{
          author:res.data[num].video_author,
          time:res.data[num].video_time,
          url:res.data[num].video_url,
          id:res.data[num].video_id,
          // list:res.data[num]
        })
        wx.request({
          url: 'https://wx.xxmtcds.top:2333/user/collectvideo',
          method:'GET',
          name:'collectList2',
          header:{
           "Content-Type": "application/json",
           authorization:app.globalData.token
         },
         success:function(res){
           console.log(res)
          wx.setStorageSync('collect2', res.data)
          wx.navigateTo({
            url: '/pages/videoo/videoo',
          })
         }
        })
       
        
      }
    })
  },
  joke:function(){
    
    wx.request({
      url: 'https://wx.xxmtcds.top:2333/user/get/joke',
      method:'GET',
      name:'music',
      header:{
        'Content-Type': 'application/json',
        authorization:app.globalData.token
  
      },
      success:function(res){
        console.log(res.data)
        // console.log(num)

        wx.setStorageSync('arrC', res.data)
        length3=res.data.length
        let num=parseInt(Math.random()*length)
        
        wx.setStorageSync('arr3',{
          content:res.data[num].joke_content,
          time:res.data[num].joke_time,
          id:res.data[num].joke_id,
          // list:res.data[num]
        })
        wx.request({
          url: 'https://wx.xxmtcds.top:2333/user/collectjoke',
          method:'GET',
          name:'collectList3',
          header:{
           "Content-Type": "application/json",
           authorization:app.globalData.token
         },
         success:function(res){
          //  console.log(res)
          wx.setStorageSync('collect3', res.data)
          wx.navigateTo({
            url: '/pages/joke/joke',
          })
         }
        })
       
        
      }
    })
  },
  onShow:function(){
    let style=wx.getStorageSync('style')
    if(style!=''){
      this.setData({
        contentStyle:wx.getStorageSync('style')
      })
    }else{
      this.setData({
        contentStyle:'https://pic.imgdb.cn/item/6199ad6c2ab3f51d91e20c91.jpg'
      })
    }
  },


})